package com.fxd.study.spring.ioc;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @author xudongfu
 * @date 2023/02/07
 * <p>
 * 该类会在所有 bean 初始化前后执行方法！！！
 */
@Component
@Slf4j
public class BeanPostProcessorImpl implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {

        log.info("开始执行 postProcessBeforeInitialization 方法，参数: {}", beanName);

        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {

        log.info("开始执行 postProcessAfterInitialization 方法，参数: {}", beanName);

        return bean;
    }
}
